package com.crm.business.crm.service;


import com.crm.common.crm.common.CrmModel;
import com.crm.common.crm.entity.BO.*;
import com.crm.common.crm.entity.PO.CrmField;
import com.crm.common.crm.entity.PO.CrmLeads;
import com.crm.common.crm.entity.PO.CrmTmkLeads;
import com.crm.common.crm.entity.VO.*;
import com.crm.common.ka.core.entity.BasePage;
import com.crm.common.ka.core.feign.crm.entity.CrmEventBO;
import com.crm.common.ka.core.feign.crm.entity.QueryEventCrmPageBO;
import com.crm.business.servlet.BaseService;
import com.crm.common.ka.core.servlet.upload.FileEntity;
import org.springframework.web.bind.annotation.RequestBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 线索表 服务类
 * </p>
 *
 * @author zhangzhiwei
 * @since 2020-05-21
 */
public interface ICrmLeadsService extends BaseService<CrmLeads> {
    /**
     * 查询字段配置
     *
     * @param id 主键ID
     * @return data
     */
    public List<CrmModelFiledVO> queryField(Integer id);

    public BasePage<Map<String, Object>> queryListByInstrumentImpl(CrmSearchBO crmSearchBO);
    public BasePage<Map<String, Object>> queryListByInstrumentImplNotLeads(CrmSearchBO crmSearchBO);

    /**
     * 分页查询
     *
     * @param search
     * @return
     */
    public BasePage<Map<String, Object>> queryPageList(@RequestBody CrmSearchBO search);

    /**
     * 查询字段配置
     *
     * @param id 主键ID
     * @return data
     */
    public CrmModel queryById(Integer id);

    /**
     * 保存或新增信息
     *
     * @param crmModel model
     * @param isExcel 是否excel
     */
    public void addOrUpdate(CrmModelSaveBO crmModel, boolean isExcel);

    /**
     * 删除线索数据
     *
     * @param ids ids
     */
    public void deleteByIds(List<Integer> ids);

    /**
     * 修改线索负责人
     *
     * @param leadsIds       线索id列表
     * @param newOwnerUserId 新负责人ID
     * @param newLeadsUserId 新线索负责人ID
     */
    public void changeOwnerUser(List<Integer> leadsIds, Long newOwnerUserId, Long newLeadsUserId);

    /**
     * 线索转客户功能
     *
     * @param leadsIds 线索id
     */
    public void transfer(CrmLeadsTransferCustomer crmLeadsTransferCustomer);

    public void transferCustomerData(Integer leadsId, CrmLeadsTransferCustomer crmLeadsTransferCustomer, List<Integer> customerIds, Map<Integer, CrmModelSaveBO> crmModelSaveBoMap);

    /**
     * 下载导入模板
     *
     * @param response 线索id
     * @throws IOException exception
     */
    public void downloadExcel(HttpServletResponse response) throws IOException;

    /**
     * 全部导出
     *
     * @param response resp
     * @param search   搜索对象
     */
    public void exportExcel(HttpServletResponse response, CrmSearchBO search);

    /**
     * tmk导出
     *
     * @param response resp
     * @param search   搜索对象
     */
    public void tmkExportExcel(HttpServletResponse response, CrmRoiSearchBO search);
    /**
     * 标星
     * @param leads 线索id
     */
    public void star(Integer leads);

    /**
     * 查询详情页基本信息
     * @param leadsId id
     * @return data
     */
    public List<CrmModelFiledVO> information(Integer leadsId);

    /**
     * 查询详情页数量
     * @param leadsId id
     * @return data
     */
    public CrmInfoNumVO num(Integer leadsId);

    /**
     * 查询文件列表
     * @param leadsId id
     * @return file
     */
    public List<FileEntity> queryFileList(Integer leadsId);

    void updateInformation(CrmUpdateInformationBO updateInformationBO);

    List<String> eventLeads(CrmEventBO crmEventBO);

    BasePage<Map<String, Object>> eventLeadsPageList(QueryEventCrmPageBO eventCrmPageBO);

    List<CrmDataCheckVO> dataCheck(CrmDataCheckBO dataCheckBO);

    /**
     * 有效表单数
     * @return
     */
    public Integer validDataNum(String laiyuan, String qishu);

    /**
     * 加客服数量
     * @param laiyuan
     * @param qishu
     * @return
     */
    public Integer addCustomerServiceNum(String laiyuan, String qishu);

    /**
     * 小额报课数量
     * @param laiyuan
     * @param qishu
     * @return
     */
    public Integer addClassReportNum(String laiyuan, String qishu);

    public CrmLeads queryLeadsDataBySerialNumber(String serialNumber);

    public Integer queryLeadsWechatDataByData(String wechat);

    public Integer queryLeadsTelephoneDataByData(String wechat);

    public List<CrmTmkLeads> queryTMKLeads(CrmRoiSearchBO search);

    void revokeTransfer(CrmLeadsTransferCustomer crmLeadsTransferCustomer);

    public Map<String,Object> queryLeadsFieldForTraining();

    public List<Map<String, Long>> queryAllLeadsStatis(String startDate, String endDate);

    public Integer queryLeadsStatisForSource(CrmRoiPutinPageBO data);

    List<CrmLeadsRoiStatisVO> queryLeadsAndCustomerStatisForData(String putinPlatform,String startDate, String endDate);

    public List<CrmLeadsRoiStatisVO> queryLeadsStatisForData(String putinPlatform,String startDate, String endDate,List<Long> userIdList);

    public List<CrmLeadsRoiStatisVO> queryRoiStatis(String startDate, String endDate);
}
